package dissertation.examples.ejb11.stateful;

import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class CountBean implements SessionBean {

    private SessionContext ctx;
    private int count;

    public void setSessionContext(SessionContext sessionContext) throws EJBException {
        ctx = sessionContext;
    }

    public void ejbRemove() throws EJBException {
        System.out.println("ejbRemove()");
    }

    public void ejbActivate() throws EJBException {
        System.out.println("ejbActivate()");
    }

    public void ejbPassivate() throws EJBException {
        System.out.println("ejbPassivate()");
    }

    @Override
    public int count() {
        System.out.println("count()");
        return ++count;
    }

    @Override
    public void ejbCreate(int count) throws CreateException {
        System.out.println("ejbCreate(" + count + ")");
        this.count = count;
    }
}
